#ifndef MODULEELECTRONICSCALESHIMADZU_H
#define MODULEELECTRONICSCALESHIMADZU_H

#include "basemodulewithport.h"
#include "moduleelectronicscaledefine.h"
#include "electronicscalerecorder.h"
#include "electronicscaleintervalrate.h"

#include <QTimer>

class ModuleElectronicScaleShimadzu : public BaseModuleWithPort
{
    Q_OBJECT
public:
    ModuleElectronicScaleShimadzu(QObject *parent = nullptr);
    virtual ~ModuleElectronicScaleShimadzu() override;

    electronicscale::ElectronicScaleParam &param();

    virtual bool setConfig(int id, QVariant &var) override;
    virtual bool getConfig(int id, QVariant &var) override;

    virtual bool setParam(int id, QVariant &var) override;
    virtual bool getParam(int id, QVariant &var) override;

public slots:
    virtual void onStart() override;
    virtual void onParseCompleted(int id, const QVariant &data) override;
    void onTimeout();
    void onTestTimeout();

private:
    electronicscale::ElectronicScaleParam       m_param;

    ElectronicScaleRecorder                 *m_recorder = nullptr;
    ElectronicScaleIntervalRate             *m_intervalRate = nullptr;

    QTimer                                  *m_timer = nullptr;
    bool                                    isGetFirstWeight = false;

    QTimer                                  *m_testTimer = nullptr;
};

#endif // MODULEELECTRONICSCALESHIMADZU_H
